package com.biz.primus.ms.search.api;

import com.biz.primus.base.vo.ProductSearchResultEntityVo;
import com.biz.primus.base.vo.commodity.ProductIdxIdentityVo;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.search.service.ProductSearchService;
import com.biz.primus.ms.search.service.SearchIndexService;
import com.biz.primus.search.vo.search.ProductSearchResultVo;
import com.biz.primus.search.vo.search.SearchProductRequestVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiangnan
 * @Description:
 */
@RestController
@RequestMapping("soa/productSearchService/")
@Api("商品搜索服务")
public class ProductSearchApiController extends BaseApiController {

    @Autowired
    private SearchIndexService searchIndexService;

    @Autowired
    private ProductSearchService productSearchService;

    @PostMapping("productIndexIncrListener")
    void productIndexIncrListener(ProductIdxIdentityVo reqVo){
        searchIndexService.productIndexIncrListener(MessageBuilder.withPayload(reqVo).build());
    }

    @PostMapping(value = "searchProduct")
    ProductSearchResultVo<ProductSearchResultEntityVo> searchProduct(@RequestBody SearchProductRequestVo vo){
        return productSearchService.searchProduct(vo);
    }


}
